﻿package core.log {
	
	import core.net.socket.CmdHandler;
	import core.net.socket.cmd.LoggerCmd;
	import com.adobe.serialization.json.JSON;
	import config.Config;
	
	public class Logger {
		
		//Socket
		private var cmdHanlder:CmdHandler = CmdHandler.getInstance();
		
		//Level  ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF
		//public static var ALL:String = "all";
		public static var DEBUG:String = "debug";
		public static var INFO:String = "info";
		public static var WARN:String = "warn";
		public static var ERROR:String = "error";
		public static var FATAL:String = "fatal";
		
		//默认 DEBUG
		/*public var level:String = Logger.DEBUG;*/
		
		//单例
		private static var instance:Logger = new Logger();
		
		public static function getInstance():Logger {
			return instance;
		}
		

		public function Logger() {
			
		}
		
		protected function log(level:String,content:String):void{
			trace(content);
			var cmd:LoggerCmd = LoggerCmd.make(level,content);
			cmdHanlder.send(cmd);
		}
		
		
		/*public function verb(content:String):void{
			this.log(Logger.VERB,content);
		}*/
		
		public function debug(content:String):void{
			if(Config.Debug){
				this.log(Logger.DEBUG,content);
			}
			
		}
		
		/*public function info(content:String):void{
			this.log(Logger.INFO,content);
		}*/
		
		public function error(content:String):void{
			this.log(Logger.ERROR,content);
		}
		
	}
	
}
